<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>

<!-- start: PAGESLIDE LEFT -->
<a class="closedbar inner hidden-sm hidden-xs" href="#"></a>
<nav id="pageslide-left" class="pageslide inner">
	<div class="navbar-content">

		<!-- start: SIDEBAR -->
		<div class="main-navigation left-wrapper transition-left ps-container">

			<div class="navigation-toggler hidden-sm hidden-xs">
				<a href="javascript:void(0);" class="sb-toggle-left">
					<i class="fa fa-ellipsis-v"></i>
				</a>
			</div>

			<!-- start: MAIN NAVIGATION MENU -->
			<ul class="main-navigation-menu">
				<c:set var="menus" value="${MENUS}" scope="session" />
                <c:import url="menu-items.jsp" />
			</ul>
			<!-- end: MAIN NAVIGATION MENU -->
		<!-- end: SIDEBAR -->
		</div>
	</div>
</nav>
<!-- end: PAGESLIDE LEFT -->

<c:set var="contextPath" value="${pageContext.request.contextPath}" />
<script type="text/javascript">
    $(function(){
    	// 根据当前请求url处理菜单
    	var requestURL = window.location.href;
    	requestURL = requestURL.substring(0, requestURL.indexOf('?') > 0 ? requestURL.indexOf('?') : requestURL.length);
    	var menus = $('a', '.main-navigation-menu');
    	if(menus && menus.length>0){
    		for(var i=0; i<menus.length; i++){
    			var menu = menus[i];
    			var match = false;
    			if(menu && menu['href']){
    				var href = menu['href'].substring(0, menu['href'].indexOf('?') > 0 ? menu['href'].indexOf('?') : menu['href'].length);
    				if(href){
    					if(href == requestURL){
    						match = true;
    					} else if(requestURL.endsWith(href)){
    						match = true;
    					}
    				}
    			}
    			if(match){
    				$(menu).parents('li').addClass('active');
    				break;
    			}
    		}
    	}
    });
</script>